<template>
	<view class="page-mine">
		<HeadCustom :home="false" :back="false" title="个人中心"></HeadCustom>
		<view class="info" @click="goLogin">
			<image class="avatar" :src="!token ? 'https://pic.imgdb.cn/item/6768e8b9d0e0a243d4e8491b.png' : 'https://pic1.imgdb.cn/item/67a8b7ddd0e0a243d4fd9629.png'" mode="widthFix"></image>
			<!-- <image src="https://pic.imgdb.cn/item/6768e946d0e0a243d4e84949.png" mode=""></image> -->
				<span v-if="!token">登录 / 注册</span>
				<span else>{{userInfo.userId}}</span>
		</view>
		<view class="other">
			<view class="item" @click="activate">
				<view class="img">
					<image src="../../static/active.png" mode=""></image>
				</view>
				<view class=""> 激活小程序 </view>
				<view class="more">
					<image src="../../static/more.png" mode=""></image>
				</view>
			</view>
			<!-- <view class="item" @click="getOwnId">
				<view class="img">
					<image src="../../static/getId.png" mode=""></image>
				</view>
				<view class=""> 获取唯一id </view>
				<view class="more">
					<image src="../../static/more.png" mode=""></image>
				</view>
			</view> -->
			<view class="item" @click="clearStorage">
				<view class="img">
					<image src="../../static/clear-us.png" mode=""></image>
				</view>
				<view class=""> 清除缓存 </view>
				<view class="more">
					<image src="../../static/more.png" mode=""></image>
				</view>
			</view>
			<view class="item" @click="aboutOur">
				<view class="img">
					<image src="../../static/about-us.png" mode=""></image>
				</view>
				<view class=""> 关于我们 </view>
				<view class="more">
					<image src="../../static/more.png" mode=""></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				token:this.$store.state.token,
				userInfo:this.$store.state.userInfo
			}
		},
		onShow() {
			this.token = this.$store.state.token
			this.userInfo = this.$store.state.userInfo
		},
		mounted() {
			console.log('this.token',this.token)
		},
		methods: {
			goLogin() {
				uni.navigateTo({
					url: '/schoolMsg/login/index'
				})
			},
			activate() {
				uni.navigateTo({
					url:'/schoolMsg/buy/index'
				})
			},
			clearStorage() {
				uni.clearStorage()
				this.$store.commit('changeToken',"")
				this.token = ""
				this.userInfo = {}
				console.log('token',this.$store.state.token)
			},
			aboutOur() {
				uni.previewImage({
					urls: ["https://pic.imgdb.cn/item/66ae47ecd9c307b7e91a9a21.png"],
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.page-mine {
		padding: 20rpx;
		.info {
			display: flex;
			align-items: center;
			.avatar {
				width: 80rpx;
				margin-right: 20rpx;
			}
		}
		.other {
			padding: 20rpx;
			.item {
				display: flex;
				position: relative;
				height: 120rpx;
				line-height: 120rpx;
				border-bottom: 2rpx solid#f7f7f9;
				padding-left: 60rpx;
			
				.img {
					position: absolute;
					top: 8rpx;
					left: -5rpx;
					width: 40rpx;
					height: 40rpx;
				}
			
				.more {
					position: absolute;
					top: 5rpx;
					right: 0;
					width: 30rpx;
					height: 30rpx;
				}
			
				.check {
					right: 70rpx;
					top: 0rpx;
				}
			
				image {
					width: 100%;
					height: 100%;
				}
			}
		}
	}
</style>